
<%@page import="ahxu.crawler.CrawlerSite"%>
<%@page import="ahxu.crawler.ICrawlerSiteDao"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="java.net.URI"%>
<%@page import="ahxu.crawler.UriInput"%>
<%@page import="ahxu.crawler.CrawlServiceProvider"%>
<%@page import="ahxu.crawler.CrawlerManager"%><%@ page language="java"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%
String[] selectedSiteIds=request.getParameterValues("crawlerSiteSelected");
if(selectedSiteIds!=null && selectedSiteIds.length>0){
    WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(application);
    CrawlerManager m=(CrawlerManager)ctx.getBean("crawlerManager");
	ICrawlerSiteDao dao=(ICrawlerSiteDao)ctx.getBean("crawlerSiteDao");
	
	for(String id:selectedSiteIds){
		CrawlerSite site=dao.findCrawlerSite(id);
		m.putCrawlerSite(site);
	}
	m.start();
	request.getSession().setAttribute("CrawlerManager", m);
	//request.getSession().setAttribute("CrawlerManagerStatus", Boolean.TRUE);
	
}
response.sendRedirect("crawler_sites.jsp");
%>